import { CommonModule, UpperCasePipe } from '@angular/common';
import { Component } from '@angular/core';
import { FormsModule } from '@angular/forms';

@Component({
  selector: 'app-my-ng-model',
  standalone: true,
    imports: [FormsModule, UpperCasePipe, CommonModule, MyDirective01Directive],
  templateUrl: './my-ng-model.component.html',
  styleUrl: './my-ng-model.component.css',
})
export class MyNgModelComponent {
  username: string = 'ding ing';
  pwd: string = '';
  showMsg: boolean = true;
  message: string = '密码长度必须是6位以上';
  // 处理输入的改变
  change() {
    console.log('数据改变', this.username);
  }

  doMouseLeave() {
    console.log('鼠标离开', 12321);
  }

  verify() {
    if (this.pwd.length < 6) {
      this.showMsg = true;
      this.message = '密码长度必须是6位以上';
    } else if (this.pwd.length > 12) {
      this.message = '密码过长了';
      this.showMsg = true;
    } else {
      this.message = '';
      this.showMsg = false;
    }
  }
}
